
local async = require[[async]]

local a = async.new()
local timed_out = function(dura) return function(t) print(t, "timed out for", dura) end end

a.on_button_press(function(t, x) print(t, x) end)

a.on_button_press(function(_, x) if x == 'q' then a:quit() end end)

local ato = timed_out('a')
a.on_button_press(function(_, x)
	if x == 'a' then
		a:timeout(ato, 1)
	elseif x == 'd' then
		a:timeout(ato)
	end
end)

a:timeout(timed_out(1), 1)
a:timeout(timed_out(0.2), 0.2)
a:timeout(timed_out(7.3), 7.3)

a:run()

